package com.itboye.ihomebank.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.controller.LoginController;
import com.itboye.ihomebank.controller.UnLoginState;
import com.itboye.ihomebank.util.SPUtils;

/**
 * 设置
 * 
 */
public class ActivitySetting extends BaseOtherActivity implements
		OnClickListener {
	ImageView close_icon;
	TextView add_shap_title_tv;
	ToggleButton toggle_button;// 切换按钮
	RelativeLayout seting_feed;// 反馈
	RelativeLayout seting_move;// 关于
	TextView seting_ok;// 退出
	public static String EXITCHANGE = "com.itboye.ihomebank.person.exit";

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.close_icon:
			finish();
			break;
		case R.id.seting_feed:// 反馈
			break;
		case R.id.seting_move:// 关于
			break;
		case R.id.seting_ok:// 退出
			exit();
			break;
		default:
			break;
		}

	}

	public void exit() {
//		SPUtils.clear(ActivitySetting.this, "share_by_data");
		deleteInfo();
		LoginController.setLoginState(new UnLoginState());

		Intent intent1 = new Intent(EXITCHANGE);
		sendBroadcast(intent1);
		ActivitySetting.this.finish();

	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_setting;
	}

	@Override
	protected void onInitController() {
		// TODO Auto-generated method stub

	}

	public void deleteInfo() {

		SPUtils.put(this, null, SPContants.USER_ID, "");
		SPUtils.put(this, null, SPContants.MOBILE, "");
		SPUtils.put(this, null, SPContants.EMAIL, "");
		SPUtils.put(this, null, SPContants.NICK, "");
		SPUtils.put(this, null, SPContants.PASSWORD, "");
		SPUtils.put(this, null, SPContants.AVATAR_URL, "");
		SPUtils.put(this, null, SPContants.USERNAME, "");
		SPUtils.put(this, null, SPContants.WX_Openid, "");
		SPUtils.put(this, null, SPContants.IS_LOGINED, false);
	}

	@Override
	protected void onInit() {
		// TODO Auto-generated method stub
		add_shap_title_tv.setText("设置");
	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}
}
